<template>
  <!-- 轮播视频 -->
  <div class="bannerVideo">
    <!-- 瀑布流展示海报 -->
    <div v-if="type == 'waterfall'" class="flex" :id="widgetData.siteId">
      <!-- 热力图 -->
      <template v-for="(ele, idx) in mapData">
        <div v-if="ele.sitePageId == widgetData.siteId" :key="idx + 'a'" class="mark"
          :style="{ background: `#${ele.color}`, opacity: 0.9 }">
          <div>
            <div class="name">PV：{{ ele.exposurePv }}</div>
            <div class="name">UV：{{ ele.exposureUv }}</div>
          </div>
          <div class="level">Lv.{{ ele.level }}</div>
        </div>
      </template>
      <!-- 视频框 -->
      <div class="video">
        <div v-if="widgetData.defaultImg != '' && widgetData.siteId == bannerVideoSideCode" style="width:100%;height:100%">
          <img :src="widgetData.defaultImg" style="width:100%;height:100%;">
        </div>
        <div v-else style="width:100%;height:100%">
          <img v-if="widgetData.value[0].url != ''" :src="widgetData.value[0].url" style="width:100%;height:100%;">
          <div v-else class="image_null"></div>
        </div>
      </div>
      <!-- 侧边栏 -->
      <div class="aside">
        <div class="items" :class="{ Border: bannerVideoSideCode == item.siteId }" v-for="(item, index) in widgetData.value"
          :key="index" @click="checkedTitle($event, item, index, widgetData)">
          <div class="title">{{ item.title }}</div>
        </div>
      </div>
    </div>

    <!-- 模板展示海报 -->
    <div v-else class="flex">
      <!-- 视频框 -->
      <div class="video">
        <div v-if="widgetData.defaultImg != ''" style="width:100%;height:100%">
          <img :src="widgetData.defaultImg" style="width:100%;height:100%;">
        </div>
        <div v-else style="width:100%;height:100%">
          <img v-if="widgetData.value[0].url != ''" :src="widgetData.value[0].url" style="width:100%;height:100%;">
          <div v-else class="image_null"></div>
        </div>
      </div>
      <!-- 侧边栏 -->
      <div class="aside">
        <div class="items" :class="{ Border: bannerVideoIndex == item.index }" v-for="(item, index) in widgetData.value"
          :key="index" @click="checkedTitle($event, item, index, widgetData)">
          <div class="title">{{ item.title }}</div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "bannerVideo",
  props: {
    type: {
      type: String,
      default: 'widget'
    },
    widgetData: {
      type: Object,
      required: true
    },
    bannerVideoIndex: {//模板参数
      type: Number,
      default: 0
    },
    bannerVideoSideCode: {//瀑布流参数
      type: String,
      default: ''
    },
    // 热力图
    mapData: {
      type: Array,
      default: () => []
    }
  },
  data() {
    return {}
  },
  methods: {
    // 选择栏目
    checkedTitle(e, item, index, data) {
      this.$emit('checkedTitle', e, item, index, data)
    },
  },
}
</script>

<style lang="scss" scoped>
.bannerVideo {
  width: 100%;
  height: 100%;

  .flex {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: flex-end;
    position: relative;

    // 热力图
    .mark {
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      padding: 10px 15px;
      display: flex;
      flex-direction: column;
      justify-content: space-between;

      .name {
        color: #ffffff;
      }

      .level {
        color: #ffffff;
        text-align: right;
      }
    }
  }

  .video {
    width: 73%;
    height: 100%;

    .image_null {
      background-color: #000000;
      width: 100%;
      height: 100%;
    }
  }

  .aside {
    width: 27%;
    height: 100%;
    border-left: 1px solid #cdcdcd;

    .items {
      background-color: #776c6c;
      font-size: 20px;
      width: 100%;
      height: 25%;
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 10px;
      border-bottom: 1px dashed #cdcdcd;

      &:nth-child(4) {
        border-bottom: none;
      }

      .title {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        color: #fff;
      }
    }

    // 选中样式
    .Border {
      border: 2px dashed rgb(0, 255, 0) !important;
    }
  }

  // 锚点定位
  .anchor {
    box-shadow: 1px 1px 10px 10px red;
  }
}
</style>